<?php
require '../database/intro.php';
$intro=new intro();
$record=$intro->getRecord();//lay tong so ban ghi
if(!isset($_GET['trang']))$_GET['trang']=1;
$vitri=($_GET['trang']-1)*10;// chon 10 ban ghi
$data=$intro->page($vitri);
?>
<style>
    #intro{
        height: 699px;
        border-bottom: 1px solid #139ff7;
    }
    #page{
        height: 60px;
    }
</style>
 <script type="text/javascript">
        $(document).ready(function(){
            $("a.del").click(function(){
               if(confirm("Bạn có muốn xóa không ?")){
                  $id=$(this).attr("name"); 
                  $(this).parent().parent().fadeOut("slow");                 
                  $.ajax({
                      "url": "modules/intro/deleteajax.php",                     
                      "type":"post",
                      "data":"uid="+$id,
                      "async":"false",
                      success: function (data) {                     
                    }
                  });
               } 
               return false;
              
            });
        });
        </script>
  <div id="intro">
            <h1>Trinh quan ly gioi thieu</h1>
        <table border="1px">
            <tr>
                <td>Id</td>
                <td>Nội dung</td>
                <td>Thao tac</td>
            </tr>
            <?php foreach ($data as $value) {?>
            <tr>
                <td><?php  echo $value['intro_id'];?></td>
                <td><?php  echo 'Noi dung'?></td>
                <td>  <a href="#">
                        <img src="images/detail.png" width="30" height="30" title="Chi tiet"></a>
                      <a href="javascript:void(0)" class="del" name="<?php echo $value['intro_id'];?>">
                        <img src="images/delete.png" width="30" height="30"title="Xoa"></a>
                      <a href='<?php echo baseurl."admin/index.php?page=intro&act=edit&id=".$value['intro_id'];?>'>
                        <img src="images/update.png"width="30" height="30" title="Cap nhat"></a></td>
            </tr>
          <?php  }?>
        </table>
</div>
        <div id="page">
 <?php $tongsotrang=  ceil($record/10);
        for($i=1;$i<=$tongsotrang;$i++)
        echo "<a href='index.php?page=intro&act=list&trang=$i'>$i</a>";
 ?>
        </div>
